package com.cn.项目.飞机预约管理系统.UserFrame;

import com.cn.项目.utils.JdbcUtils;

import javax.swing.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import static com.cn.项目.飞机预约管理系统.UserFrame.MyPessenger.name;
public class ShowPassenfer extends JPanel {
    Vector rowDate, columnNames;
    JTable jt;
    JScrollPane jsp;

    public ShowPassenfer(){
        MyPessenger myPessenger = new MyPessenger();
        System.out.println(name);
        Connection conn = null;
        PreparedStatement st = null;
        ResultSet rs =null;
        columnNames = new Vector();
        columnNames.add("乘客姓名");
        columnNames.add("身份证");
        columnNames.add("照片(二进制)");
        columnNames.add("代买人");

        rowDate = new Vector();
        try {
            conn = JdbcUtils.getConnection();
            String sql = "select *from passenger where dname=? ";
            st = conn.prepareStatement(sql);
            st.setString(1,name );
            rs = st.executeQuery();
            while (rs.next()) {
                Vector hang = new Vector();
                hang.add(rs.getString(1));
                hang.add(rs.getString(2));
                hang.add(rs.getString(3));
                hang.add(rs.getString(4));
                rowDate.add(hang);
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            JdbcUtils.release(conn, st, rs);
        }

        jt = new JTable(rowDate, columnNames);
        jsp = new JScrollPane(jt);
        this.add(jsp);
        this.setVisible(true);
    }
}
